package top.sqdpt.rag.tools;

import dev.langchain4j.agent.tool.Tool;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;

public class AiComputeTool {

    @Tool(name = "当前时间", value = "获取当前时间")
    public static String getDateNow() {
        return LocalDateTime.now().toString();
    }

    @Tool(name = "加法运算", value = "计算a和b两个值之和")
    public static String add(BigDecimal a, BigDecimal b) {
        return a.add(b).toString();
    }

    @Tool(name = "减法运算", value = "计算a减b")
    public static String subtract(BigDecimal a, BigDecimal b) {
        return a.subtract(b).toString();
    }

    @Tool(name = "乘法运算", value = "计算a乘b")
    public static String multiply(BigDecimal a, BigDecimal b) {
        return a.multiply(b).toString();
    }

    @Tool(name = "除法运算", value = "计算a除以b")
    public static String divide(BigDecimal a, BigDecimal b) {
        return a.divide(b, 4, RoundingMode.CEILING).toString();
    }

    @Tool("Returns a square root of a given number")
    double squareRoot(double x) {
        return Math.sqrt(x);
    }


}
